4
4
.
.
4
4
.
.
5
5
C
C
a
a
p
p
s
s
u
u
l
l
e
e
I
I
n
n
f
f
o
o
[
[
R
R
]
]
This tutorials shows how to add View in the shape of the Capsule.
Capsule draws a box where longer dimensions is fully rounded.
You can't combine fill and stroke on the same Capsule.
Fill
struct ContentView : View {
var body : some View {
Capsule()
.rotation(.degrees(45))
.fill(Color.green)
.frame(width: 100, height: 50)
}
}
Stroke
struct ContentView : View {
var body : some View {
Capsule()
.rotation(.degrees(45))
.stroke(Color.green, lineWidth: 2)
.frame(width: 100, height: 50)
}
}
Fill Stroke